<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>代理模式</title>
</head>
<body>
<script>
    //A2B
    function A(){
        this.money="20RMB";
    }
    function to(){
        if(!(this instanceof to)){
            return new to;
        }
    }
    to.prototype.maifang=function(){
        var a=new A();
        new B().maifang(a.money);
    }
    function B(){
        this.maifang=function(money){
            alert("收到了钱"+money)
        }
    }
    (new to()).maifang();
    to().maifang();
</script>
</body>
</html>